home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Magazine 28 Bonus
/
CDRomMagazine-SoftKey-ArtPassion-FrenchVersion-Win31Mac.bin
/
data
/
cnfeepl.dir
/
00016_Script_MAIN HANDLERS
< prev
next >
Wrap
Text File
|
1996-06-18
|
7KB
|
233 lines
-- What is this?
-- The FeelingsGame. Drag a shape button to one of the frames and express your own
-- feeling. A shape will 'snap back' to it's button when not released in a frame and
-- you canonly drag 5 of every shapes. After that, the button will grey out and is not active.
-- How does it work?
-- On top of each shape button at te bottom of the screen are 5 empty sprites.Each sprite contains
-- a call to handler processClick when clicked. Then the corresponding castmember (a shape) is
-- substituted for the castmember of the empty sprite.While dragged, it follows the mouse and when
-- released it stays in place (if it's within an invisible castmember ofverlaying the painting
-- frame or snaps back if it's not. A counter keeps track of te amount of shapes used for each
-- button. If this is 5 (max) then the castmember of the last empty sprite overlaying the button
-- is switched for a grayed out version of the button.
on initGame
global paintingSpritesList
global buttonShapesSpritesSizeWList,buttonShapesSpritesSizeHList
global cCrook,cTriangle,caLine,cSquare,cCircle,cinvTriangle
global firstShapeSprite,lastShapeSprite,ExampleButtonsSprite
global placedSprites
-- set the puppets of the shapes buttons
set firstShapeSprite = 10
set lastShapeSprite = 39
setPuppetsFromTo 10,39,1
-- set the counters of the shapes to 0
set cCrook = 0
set cTriangle = 0
set caLine = 0
set cSquare = 0
set cCircle = 0
set cinvTriangle = 0
-- these are the Horizontal coordinates of the sprites containing the shapes
set buttonShapesSpritesSizeWList = [Crook:41,aTriangle:46,aLine:5,Square:40,Circle:31,InvTriangle:28]
-- these are the Vertical coordinates of the sprites containing the shapes
set buttonShapesSpritesSizeHList= [Crook:72,aTriangle:33,aLine:59,Square:45,¼
Circle:31,InvTriangle:24]
-- these are the nrs of the invisible sprites overlaying the painting frames
set paintingSpritesList = [6,7,8,9]
-- initialize the list that contains the spritenrs of shapes that are dragged
set placedSprites = []
end initGame
on processClick aSprite,aShape
global buttonShapesSpritesSizeWList,buttonShapesSpritesSizeHList
-- remember original position of buttonsprite if you have to reset it (resetShape)
set oldShapeLocH = the locH of sprite aSprite
set oldShapeLocV = the locV of sprite aSprite
set oldLoc = [oldShapeLocH,oldShapeLocV]
-- remember the castNr of the empty buttonSprite if you have to reset it (resetShape)
set oldCast = the castNum of sprite aSprite
-- remember the size of the empty buttonSprite if you have to reset it (resetShape)
set oldSpriteHeight = the height of sprite aSprite
set oldSpriteWidth = the width of sprite aSprite
set oldSpriteSize = [oldSpriteHeight,oldSpriteWidth]
-- change the empty buttonSprite size to the shape's size
set the width of sprite aSprite to (getAProp(buttonShapesSpritesSizeWList,aShape))
set the height of sprite aSprite to (getAProp(buttonShapesSpritesSizeHList,aShape))
updateStage
-- change empty buttonSprite to the shape
set the castNum of sprite aSprite to the number of cast string(aShape)
-- drag shape
repeat while the stillDown
set the locH of sprite aSprite to the mouseH
set the locV of sprite aSprite to the mouseV
updateStage
end repeat
-- shape is dropped - check
if NOT intoFrame(aSprite) then resetShape aSprite,oldCast,oldLoc,oldSpriteSize
else
if NOT firstTimeShapeDragged(aSprite) then
addCounter aShape,aSprite
addShapeToPlacedShapesList(aSprite) -- add the sprite that's already dragged to a list
end if
end if
end processClick
-- when shape is dropped, & it is IN a picture frame, leave it there
-- when shape is dropped, & it is NOT IN a picture frame, snap back to button
on intoFrame aSprite
global paintingSpritesList
set snappedIntoPlace = FALSE
set i = 1
repeat while (NOT snappedIntoPlace) AND (i <= 4)
set currPaintingFrame = getAt(paintingSpritesList,i)
if sprite aSprite within currPaintingFrame then set snappedIntoPlace = TRUE
set i = i + 1
end repeat
return snappedIntoPlace
end intoFrame
on resetShape aSprite,oldCastNr,oldPos,oldSize
-- reset cast
set the castNum of sprite aSprite to oldCastNr
-- reset location
set the locH of sprite aSprite to getAt(oldPos,1)
set the locV of sprite aSprite to getAt(oldPos,2)
-- reset size
set the height of sprite aSprite = getAt(oldSize,1)
set the width of sprite aSprite = getAt(oldSize,2)
end resetShape
-- keep track how many shapes are used.
on addCounter aShape,aSprite
global cCrook,cTriangle,caLine,cSquare,cCircle,cinvTriangle
if aShape = "Crook" then
set cCrook = cCrook + 1
checkCounter cCrook,"Crook",aSprite
end if
if aShape = "aTriangle" then
set cTriangle = cTriangle + 1
checkCounter cTriangle,"aTriangle",aSprite
end if
if aShape = "aLine" then
set caLine = caLine + 1
checkCounter caLine,"aLine",aSprite
end if
if aShape = "Square" then
set cSquare = cSquare + 1
checkCounter cSquare,"Square",aSprite
end if
if aShape = "Circle" then
set cCircle = cCircle + 1
checkCounter cCircle,"Circle",aSprite
end if
if aShape = "invTriangle" then
set cinvTriangle = cinvTriangle + 1
checkCounter cinvTriangle,"invTriangle",aSprite
end if
end addCounter
-- Change the shapebutton to Inactive (grey) when the last shape is used
on checkCounter aCounter,aShape,aSprite
set lastSprite = aSprite - 1
if aCounter = 4 then
disableButton lastSprite
end if
updateStage
end checkCounter
-- handler shapePlacedInFrame adds a sprite to a list
on addShapeToPlacedShapesList aSprite
global placedSprites
add(placedSprites, aSprite)
end
on firstTimeShapeDragged aSprite
global placedSprites
return inList(placedSprites,aSprite)
end
-- --------------------------------------------------------
-- Handler pressButton changes the apparance of the button
-- to it's pressed equivalent as long as user presses the mouse
-- and the cursor is over the button
on pressButton
global buttonPressed
repeat while the mouseDown
if NOT rollOver(the clickOn) then
changeButtonCast the clickOn, "out"
set buttonPressed = FALSE
else
changeButtonCast the clickOn, "in"
set buttonPressed = TRUE
end if
updateStage
end repeat
changeButtonCast the clickOn, "out"
end
-- ---------------------------------------------------------------
-- Handler inList returns TRUE if 'anItem' is in the list 'aList',
-- FALSE if 'anItem' is not in the list 'aList'.
on inList aList,anItem
set result = FALSE
repeat with i = 1 to count(aList)
if getAt(aList,i) = anItem then
set result = TRUE
exit repeat
end if
end repeat
return result
end